package ace.j2se.l2;

import java.lang.reflect.Field;

public class ReflectStudent {
	private String name;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public static void main(String[] args) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
		ReflectStudent stu=new ReflectStudent();
		Field[]fields=stu.getClass().getDeclaredFields();
		for(Field f:fields){
			System.out.println(f.getName());
		}
		
		Class cls=ReflectStudent.class;
		Field f=cls.getDeclaredField(fields[0].getName());
		System.out.println(f);
		f.set(stu, "aaa");
		System.out.println(stu.getName());
		
	}
}
